<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module Coverage - coverage: Ruby Standard Library Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#module-Coverage-label-Usage">Usage</a>
    <li><a href="#module-Coverage-label-Examples">Examples</a>
    <li><a href="#module-Coverage-label-Lines+Coverage">Lines Coverage</a>
    <li><a href="#module-Coverage-label-Oneshot+Lines+Coverage">Oneshot Lines Coverage</a>
    <li><a href="#module-Coverage-label-Branches+Coverage">Branches Coverage</a>
    <li><a href="#module-Coverage-label-Methods+Coverage">Methods Coverage</a>
    <li><a href="#module-Coverage-label-All+Coverage+Modes">All Coverage Modes</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-line_stub">::line_stub</a>
    <li ><a href="#method-c-peek_result">::peek_result</a>
    <li ><a href="#method-c-result">::result</a>
    <li ><a href="#method-c-resume">::resume</a>
    <li ><a href="#method-c-running-3F">::running?</a>
    <li ><a href="#method-c-setup">::setup</a>
    <li ><a href="#method-c-start">::start</a>
    <li ><a href="#method-c-state">::state</a>
    <li ><a href="#method-c-supported-3F">::supported?</a>
    <li ><a href="#method-c-suspend">::suspend</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-Coverage">
    <h1 id="module-Coverage" class="module">
      module Coverage
    </h1>

    <section class="description">
    
<p><a href="Coverage.html"><code>Coverage</code></a> provides coverage measurement feature for Ruby. This feature is experimental, so these APIs may be changed in future.</p>

<p>Caveat: Currently, only process-global coverage measurement is supported. You cannot measure per-thread coverage.</p>

<h1 id="module-Coverage-label-Usage">Usage<span><a href="#module-Coverage-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h1>
<ol><li>
<p>require “coverage”</p>
</li><li>
<p>do <a href="Coverage.html#method-c-start"><code>Coverage.start</code></a></p>
</li><li>
<p>require or load Ruby source file</p>
</li><li>
<p><a href="Coverage.html#method-c-result"><code>Coverage.result</code></a> will return a hash that contains filename as key and coverage array as value. A coverage array gives, for each line, the number of line execution by the interpreter. A <code>nil</code> value means coverage is disabled for this line (lines like <code>else</code> and <code>end</code>).</p>
</li></ol>

<h1 id="module-Coverage-label-Examples">Examples<span><a href="#module-Coverage-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h1>

<pre class="ruby">[<span class="ruby-identifier">foo</span>.<span class="ruby-identifier">rb</span>]
<span class="ruby-identifier">s</span> = <span class="ruby-value">0</span>
<span class="ruby-value">10</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">s</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">x</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">if</span> <span class="ruby-identifier">s</span> <span class="ruby-operator">==</span> <span class="ruby-value">45</span>
  <span class="ruby-identifier">p</span> <span class="ruby-value">:ok</span>
<span class="ruby-keyword">else</span>
  <span class="ruby-identifier">p</span> <span class="ruby-value">:ng</span>
<span class="ruby-keyword">end</span>
[<span class="ruby-constant">EOF</span>]

<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;coverage&quot;</span>
<span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">start</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;foo.rb&quot;</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">result</span>  <span class="ruby-comment">#=&gt; {&quot;foo.rb&quot;=&gt;[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}</span>
</pre>

<h2 id="module-Coverage-label-Lines+Coverage">Lines <a href="Coverage.html"><code>Coverage</code></a><span><a href="#module-Coverage-label-Lines+Coverage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>If a coverage mode is not explicitly specified when starting coverage, lines coverage is what will run. It reports the number of line executions for each line.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&quot;coverage&quot;</span>
<span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">lines:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;foo.rb&quot;</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">result</span> <span class="ruby-comment">#=&gt; {&quot;foo.rb&quot;=&gt;{:lines=&gt;[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}}</span>
</pre>

<p>The value of the lines coverage result is an array containing how many times each line was executed. Order in this array is important. For example, the first item in this array, at index 0, reports how many times line 1 of this file was executed while coverage was run (which, in this example, is one time).</p>

<p>A <code>nil</code> value means coverage is disabled for this line (lines like <code>else</code> and <code>end</code>).</p>

<h2 id="module-Coverage-label-Oneshot+Lines+Coverage">Oneshot Lines <a href="Coverage.html"><code>Coverage</code></a><span><a href="#module-Coverage-label-Oneshot+Lines+Coverage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Oneshot lines coverage tracks and reports on the executed lines while coverage is running. It will not report how many times a line was executed, only that it was executed.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&quot;coverage&quot;</span>
<span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">oneshot_lines:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;foo.rb&quot;</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">result</span> <span class="ruby-comment">#=&gt; {&quot;foo.rb&quot;=&gt;{:oneshot_lines=&gt;[1, 2, 3, 6, 7]}}</span>
</pre>

<p>The value of the oneshot lines coverage result is an array containing the line numbers that were executed.</p>

<h2 id="module-Coverage-label-Branches+Coverage">Branches <a href="Coverage.html"><code>Coverage</code></a><span><a href="#module-Coverage-label-Branches+Coverage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Branches coverage reports how many times each branch within each conditional was executed.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&quot;coverage&quot;</span>
<span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">branches:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;foo.rb&quot;</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">result</span> <span class="ruby-comment">#=&gt; {&quot;foo.rb&quot;=&gt;{:branches=&gt;{[:if, 0, 6, 0, 10, 3]=&gt;{[:then, 1, 7, 2, 7, 7]=&gt;1, [:else, 2, 9, 2, 9, 7]=&gt;0}}}}</span>
</pre>

<p>Each entry within the branches hash is a conditional, the value of which is another hash where each entry is a branch in that conditional. The values are the number of times the method was executed, and the keys are identifying information about the branch.</p>

<p>The information that makes up each key identifying branches or conditionals is the following, from left to right:</p>
<ol><li>
<p>A label for the type of branch or conditional.</p>
</li><li>
<p>A unique identifier.</p>
</li><li>
<p>The starting line number it appears on in the file.</p>
</li><li>
<p>The starting column number it appears on in the file.</p>
</li><li>
<p>The ending line number it appears on in the file.</p>
</li><li>
<p>The ending column number it appears on in the file.</p>
</li></ol>

<h2 id="module-Coverage-label-Methods+Coverage">Methods <a href="Coverage.html"><code>Coverage</code></a><span><a href="#module-Coverage-label-Methods+Coverage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Methods coverage reports how many times each method was executed.</p>

<pre class="ruby">[<span class="ruby-identifier">foo_method</span>.<span class="ruby-identifier">rb</span>]
<span class="ruby-keyword">class</span> <span class="ruby-constant">Greeter</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">greet</span>
    <span class="ruby-string">&quot;welcome!&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">hello</span>
  <span class="ruby-string">&quot;Hi&quot;</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">hello</span>()
<span class="ruby-constant">Greeter</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">greet</span>()
[<span class="ruby-constant">EOF</span>]

<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;coverage&quot;</span>
<span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">methods:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;foo_method.rb&quot;</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">result</span> <span class="ruby-comment">#=&gt; {&quot;foo_method.rb&quot;=&gt;{:methods=&gt;{[Object, :hello, 7, 0, 9, 3]=&gt;1, [Greeter, :greet, 2, 2, 4, 5]=&gt;1}}}</span>
</pre>

<p>Each entry within the methods hash represents a method. The values in this hash are the number of times the method was executed, and the keys are identifying information about the method.</p>

<p>The information that makes up each key identifying a method is the following, from left to right:</p>
<ol><li>
<p>The class.</p>
</li><li>
<p>The method name.</p>
</li><li>
<p>The starting line number the method appears on in the file.</p>
</li><li>
<p>The starting column number the method appears on in the file.</p>
</li><li>
<p>The ending line number the method appears on in the file.</p>
</li><li>
<p>The ending column number the method appears on in the file.</p>
</li></ol>

<h2 id="module-Coverage-label-All+Coverage+Modes">All <a href="Coverage.html"><code>Coverage</code></a> Modes<span><a href="#module-Coverage-label-All+Coverage+Modes">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>You can also run all modes of coverage simultaneously with this shortcut. Note that running all coverage modes does not run both lines and oneshot lines. Those modes cannot be run simultaneously. Lines coverage is run in this case, because you can still use it to determine whether or not a line was executed.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&quot;coverage&quot;</span>
<span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">:all</span>)
<span class="ruby-identifier">require</span> <span class="ruby-string">&quot;foo.rb&quot;</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">result</span> <span class="ruby-comment">#=&gt; {&quot;foo.rb&quot;=&gt;{:lines=&gt;[1, 1, 10, nil, nil, 1, 1, nil, 0, nil], :branches=&gt;{[:if, 0, 6, 0, 10, 3]=&gt;{[:then, 1, 7, 2, 7, 7]=&gt;1, [:else, 2, 9, 2, 9, 7]=&gt;0}}, :methods=&gt;{}}}</span>
</pre>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-line_stub" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">line_stub</span><span
                                class="method-args">(file)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="line_stub-source">
            <pre><span class="ruby-comment"># File coverage/lib/coverage.rb, line 4</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">line_stub</span>(<span class="ruby-identifier">file</span>)
  <span class="ruby-identifier">lines</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">foreach</span>(<span class="ruby-identifier">file</span>).<span class="ruby-identifier">map</span> { <span class="ruby-keyword">nil</span> }
  <span class="ruby-identifier">iseqs</span> = [<span class="ruby-constant">RubyVM</span><span class="ruby-operator">::</span><span class="ruby-constant">InstructionSequence</span>.<span class="ruby-identifier">compile_file</span>(<span class="ruby-identifier">file</span>)]
  <span class="ruby-keyword">until</span> <span class="ruby-identifier">iseqs</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">iseq</span> = <span class="ruby-identifier">iseqs</span>.<span class="ruby-identifier">pop</span>
    <span class="ruby-identifier">iseq</span>.<span class="ruby-identifier">trace_points</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span>, <span class="ruby-identifier">type</span><span class="ruby-operator">|</span> <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">n</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>] = <span class="ruby-value">0</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:line</span> }
    <span class="ruby-identifier">iseq</span>.<span class="ruby-identifier">each_child</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span> <span class="ruby-identifier">iseqs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">child</span> }
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">lines</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-peek_result" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          peek_result  &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a hash that contains filename as key and coverage array as value. This is the same as ‘Coverage.result(stop: false, clear: false)`.</p>

<pre>{
  &quot;file.rb&quot; =&gt; [1, 2, nil],
  ...
}</pre>

                              <div class="method-source-code" id="peek_result-source">
            <pre>static VALUE
rb_coverage_peek_result(VALUE klass)
{
    VALUE coverages = rb_get_coverages();
    VALUE ncoverages = rb_hash_new();
    if (!RTEST(coverages)) {
        rb_raise(rb_eRuntimeError, &quot;coverage measurement is not enabled&quot;);
    }
    OBJ_WB_UNPROTECT(coverages);
    st_foreach(RHASH_TBL_RAW(coverages), coverage_peek_result_i, ncoverages);

    if (current_mode &amp; COVERAGE_TARGET_METHODS) {
        rb_objspace_each_objects(method_coverage_i, &amp;ncoverages);
    }

    rb_hash_freeze(ncoverages);
    return ncoverages;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-result" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          result(stop: true, clear: true)  &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a hash that contains filename as key and coverage array as value. If <code>clear</code> is true, it clears the counters to zero. If <code>stop</code> is true, it disables coverage measurement.</p>

                              <div class="method-source-code" id="result-source">
            <pre>static VALUE
rb_coverage_result(int argc, VALUE *argv, VALUE klass)
{
    VALUE ncoverages;
    VALUE opt;
    int stop = 1, clear = 1;

    if (current_state == IDLE) {
        rb_raise(rb_eRuntimeError, &quot;coverage measurement is not enabled&quot;);
    }

    rb_scan_args(argc, argv, &quot;01&quot;, &amp;opt);

    if (argc == 1) {
        opt = rb_convert_type(opt, T_HASH, &quot;Hash&quot;, &quot;to_hash&quot;);
        stop = RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern(&quot;stop&quot;))));
        clear = RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern(&quot;clear&quot;))));
    }

    ncoverages = rb_coverage_peek_result(klass);
    if (stop &amp;&amp; !clear) {
        rb_warn(&quot;stop implies clear&quot;);
        clear = 1;
    }
    if (clear) {
        rb_clear_coverages();
        if (!NIL_P(me2counter)) rb_hash_foreach(me2counter, clear_me2counter_i, Qnil);
    }
    if (stop) {
        if (current_state == RUNNING) {
            rb_coverage_suspend(klass);
        }
        rb_reset_coverages();
        me2counter = Qnil;
        current_state = IDLE;
    }
    return ncoverages;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-resume" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          resume  &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Start/resume the coverage measurement.</p>

<p>Caveat: Currently, only process-global coverage measurement is supported. You cannot measure per-thread coverage. If your process has multiple thread, using <a href="Coverage.html#method-c-resume"><code>Coverage.resume</code></a>/suspend to capture code coverage executed from only a limited code block, may yield misleading results.</p>

                              <div class="method-source-code" id="resume-source">
            <pre>VALUE
rb_coverage_resume(VALUE klass)
{
    if (current_state == IDLE) {
        rb_raise(rb_eRuntimeError, &quot;coverage measurement is not set up yet&quot;);
    }
    if (current_state == RUNNING) {
        rb_raise(rb_eRuntimeError, &quot;coverage measurement is already running&quot;);
    }
    rb_resume_coverages();
    current_state = RUNNING;
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-running-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          running?  &rarr; bool
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if coverage stats are currently being collected (after <a href="Coverage.html#method-c-start"><code>Coverage.start</code></a> call, but before <a href="Coverage.html#method-c-result"><code>Coverage.result</code></a> call)</p>

                              <div class="method-source-code" id="running-3F-source">
            <pre>static VALUE
rb_coverage_running(VALUE klass)
{
    return current_state == RUNNING ? Qtrue : Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-setup" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          setup                                                          &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          setup(:all)                                                    &rarr; nil
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          setup(lines: bool, branches: bool, methods: bool, eval: bool)  &rarr; nil
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          setup(oneshot_lines: true)                                     &rarr; nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Set up the coverage measurement.</p>

<p>Note that this method does not start the measurement itself. Use <a href="Coverage.html#method-c-resume"><code>Coverage.resume</code></a> to start the measurement.</p>

<p>You may want to use <a href="Coverage.html#method-c-start"><code>Coverage.start</code></a> to setup and then start the measurement.</p>

                              <div class="method-source-code" id="setup-source">
            <pre>static VALUE
rb_coverage_setup(int argc, VALUE *argv, VALUE klass)
{
    VALUE coverages, opt;
    int mode;

    if (current_state != IDLE) {
        rb_raise(rb_eRuntimeError, &quot;coverage measurement is already setup&quot;);
    }

    rb_scan_args(argc, argv, &quot;01&quot;, &amp;opt);

    if (argc == 0) {
        mode = 0; /* compatible mode */
    }
    else if (opt == ID2SYM(rb_intern(&quot;all&quot;))) {
        mode = COVERAGE_TARGET_LINES | COVERAGE_TARGET_BRANCHES | COVERAGE_TARGET_METHODS | COVERAGE_TARGET_EVAL;
    }
    else {
        mode = 0;
        opt = rb_convert_type(opt, T_HASH, &quot;Hash&quot;, &quot;to_hash&quot;);

        if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern(&quot;lines&quot;)))))
            mode |= COVERAGE_TARGET_LINES;
        if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern(&quot;branches&quot;)))))
            mode |= COVERAGE_TARGET_BRANCHES;
        if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern(&quot;methods&quot;)))))
            mode |= COVERAGE_TARGET_METHODS;
        if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern(&quot;oneshot_lines&quot;))))) {
            if (mode &amp; COVERAGE_TARGET_LINES)
                rb_raise(rb_eRuntimeError, &quot;cannot enable lines and oneshot_lines simultaneously&quot;);
            mode |= COVERAGE_TARGET_LINES;
            mode |= COVERAGE_TARGET_ONESHOT_LINES;
        }
        if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern(&quot;eval&quot;)))))
            mode |= COVERAGE_TARGET_EVAL;
    }

    if (mode &amp; COVERAGE_TARGET_METHODS) {
        me2counter = rb_ident_hash_new();
    }
    else {
        me2counter = Qnil;
    }

    coverages = rb_get_coverages();
    if (!RTEST(coverages)) {
        coverages = rb_hash_new();
        rb_obj_hide(coverages);
        current_mode = mode;
        if (mode == 0) mode = COVERAGE_TARGET_LINES;
        rb_set_coverages(coverages, mode, me2counter);
        current_state = SUSPENDED;
    }
    else if (current_mode != mode) {
        rb_raise(rb_eRuntimeError, &quot;cannot change the measuring target during coverage measurement&quot;);
    }

    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-start" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          start                                                          &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          start(:all)                                                    &rarr; nil
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          start(lines: bool, branches: bool, methods: bool, eval: bool)  &rarr; nil
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          start(oneshot_lines: true)                                     &rarr; nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Enables the coverage measurement. See the documentation of <a href="Coverage.html"><code>Coverage</code></a> class in detail. This is equivalent to <a href="Coverage.html#method-c-setup"><code>Coverage.setup</code></a> and <a href="Coverage.html#method-c-resume"><code>Coverage.resume</code></a>.</p>

                              <div class="method-source-code" id="start-source">
            <pre>static VALUE
rb_coverage_start(int argc, VALUE *argv, VALUE klass)
{
    rb_coverage_setup(argc, argv, klass);
    rb_coverage_resume(klass);
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-state" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          state  &rarr; :idle, :suspended, :running
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the state of the coverage measurement.</p>

                              <div class="method-source-code" id="state-source">
            <pre>static VALUE
rb_coverage_state(VALUE klass)
{
    switch (current_state) {
        case IDLE: return ID2SYM(rb_intern(&quot;idle&quot;));
        case SUSPENDED: return ID2SYM(rb_intern(&quot;suspended&quot;));
        case RUNNING: return ID2SYM(rb_intern(&quot;running&quot;));
    }
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-supported-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          supported?(mode) &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if coverage measurement is supported for the given mode.</p>

<p>The mode should be one of the following symbols: <code>:lines</code>, <code>:oneshot_lines</code>, <code>:branches</code>, <code>:methods</code>, <code>:eval</code>.</p>

<p>Example:</p>

<pre class="ruby"><span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">supported?</span>(<span class="ruby-value">:lines</span>)  <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">Coverage</span>.<span class="ruby-identifier">supported?</span>(<span class="ruby-value">:all</span>)    <span class="ruby-comment">#=&gt; false</span>
</pre>

                              <div class="method-source-code" id="supported-3F-source">
            <pre>static VALUE
rb_coverage_supported(VALUE self, VALUE _mode)
{
    ID mode = RB_SYM2ID(_mode);

    return RBOOL(
        mode == rb_intern(&quot;lines&quot;) ||
        mode == rb_intern(&quot;oneshot_lines&quot;) ||
        mode == rb_intern(&quot;branches&quot;) ||
        mode == rb_intern(&quot;methods&quot;) ||
        mode == rb_intern(&quot;eval&quot;)
    );
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-suspend" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          suspend  &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Suspend the coverage measurement. You can use <a href="Coverage.html#method-c-resume"><code>Coverage.resume</code></a> to restart the measurement.</p>

                              <div class="method-source-code" id="suspend-source">
            <pre>VALUE
rb_coverage_suspend(VALUE klass)
{
    if (current_state != RUNNING) {
        rb_raise(rb_eRuntimeError, &quot;coverage measurement is not running&quot;);
    }
    rb_suspend_coverages();
    current_state = SUSPENDED;
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

